And change its callers to handle it that way.
GtkTargetList *target_list = gtk_target_list_new (NULL, 0);
guint actions = entry->editable ? GDK_ACTION_COPY | GDK_ACTION_MOVE : GDK_ACTION_COPY;
gchar *text = NULL;
- GdkPixmap *pixmap = NULL;
+ cairo_surface_t *surface;
gtk_target_list_add_text_targets (target_list, 0);
text = _gtk_entry_get_selected_text (entry);
- pixmap = _gtk_text_util_create_drag_icon (widget, text, -1);
+ surface = _gtk_text_util_create_drag_icon (widget, text, -1);
context = gtk_drag_begin (widget, target_list, actions,
entry->button, (GdkEvent *)event);
- if (pixmap)
- gtk_drag_set_icon_pixmap (context,
- gdk_drawable_get_colormap (pixmap),
- pixmap,
- NULL,
- -2, -2);
+ if (surface)
+ gtk_drag_set_icon_surface (context, surface);
else
gtk_drag_set_icon_default (context);
- if (pixmap)
- g_object_unref (pixmap);
+ if (surface)
+ cairo_surface_destroy (surface);
g_free (text);
entry->in_drag = FALSE;
{
GtkLabel *label = GTK_LABEL (widget);
GtkLabelPrivate *priv = label->priv;
- GdkPixmap *pixmap = NULL;
+ cairo_surface_t *surface = NULL;
g_signal_handlers_disconnect_by_func (widget, drag_begin_cb, NULL);
if (start > len)
start = len;
- pixmap = _gtk_text_util_create_drag_icon (widget,
- priv->text + start,
- end - start);
+ surface = _gtk_text_util_create_drag_icon (widget,
+ priv->text + start,
+ end - start);
}
- if (pixmap)
- gtk_drag_set_icon_pixmap (context,
- gdk_drawable_get_colormap (pixmap),
- pixmap,
- NULL,
- -2, -2);
+ if (surface)
+ gtk_drag_set_icon_surface (context, surface);
else
gtk_drag_set_icon_default (context);
- if (pixmap)
- g_object_unref (pixmap);
+ if (surface)
+ g_object_unref (surface);
}
static gboolean
*
* Creates a drag and drop icon from @text.
*
- * Returns: a #GdkPixmap to use as DND icon
+ * Returns: a #cairo_surface_t to use as DND icon
*/
-GdkPixmap *
+cairo_surface_t *
_gtk_text_util_create_drag_icon (GtkWidget *widget,
gchar *text,
gsize len)
{
GtkStyle *style;
GtkStateType state;
- GdkDrawable *drawable = NULL;
+ cairo_surface_t *surface;
PangoContext *context;
PangoLayout *layout;
cairo_t *cr;
pixmap_width = layout_width / PANGO_SCALE + DRAG_ICON_LAYOUT_BORDER * 2;
pixmap_height = layout_height / PANGO_SCALE + DRAG_ICON_LAYOUT_BORDER * 2;
- drawable = gdk_pixmap_new (gtk_widget_get_window (widget),
- pixmap_width + 2,
- pixmap_height + 2,
- -1);
- cr = gdk_cairo_create (drawable);
style = gtk_widget_get_style (widget);
state = gtk_widget_get_state (widget);
+ surface = gdk_window_create_similar_surface (gtk_widget_get_window (widget),
+ CAIRO_CONTENT_COLOR,
+ pixmap_width + 2,
+ pixmap_height + 2);
+ cr = cairo_create (surface);
gdk_cairo_set_source_color (cr, &style->base [state]);
cairo_paint (cr);
cairo_destroy (cr);
g_object_unref (layout);
- return drawable;
+ cairo_surface_set_device_offset (surface, 2, 2);
+
+ return surface;
}
static void
GtkTextUtilCharChosenFunc func,
gpointer data);
-GdkPixmap* _gtk_text_util_create_drag_icon (GtkWidget *widget,
- gchar *text,
- gsize len);
+cairo_surface_t * _gtk_text_util_create_drag_icon (GtkWidget *widget,
+ gchar *text,
+ gsize len);
GdkPixmap* _gtk_text_util_create_rich_drag_icon (GtkWidget *widget,
GtkTextBuffer *buffer,
GtkTextIter *start,